package com.bk.controller;

import com.bk.domain.Collection;
import com.bk.service.CollectionService;
import com.bk.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("cc")
public class CollectionController {
    @Autowired
    private CollectionService collectionService;

    @GetMapping("{id}")
    public Result getCollection(@PathVariable Long id){
        return collectionService.getCollection(id);
    }

    @PostMapping
    public Result addCollection(@RequestBody Collection collection) {
        return collectionService.addCollection(collection);
    }

    @DeleteMapping("{id}")
    public Result deleteCollection(@PathVariable Long id) {
        return collectionService.deleteCollection(id);
    }
    @PutMapping
    public Result updateCollection(@RequestBody Collection collection) {
        return collectionService.updateCollection(collection);
    }

    @GetMapping
    public Result getAll() {
        return Result.success(collectionService.list());
    }
}
